package application;

import java.util.Date;

import de.fhhannover.inform.persistence.Broker;
import de.fhhannover.inform.persistence.Transaction;

public class main {

	public static void main(String[] args) {
		System.out.println("ERSTELLEN BEGINNEN");

		try {
/*
			// --- Person Objekt ---
			System.out.println("PERSON ERSTELLEN BEGINNEN");
			Person p1 = new Person();
			p1.setName("floriannn", "hoffmann");
			// p1.setGeburtstag(05.09.2000);
			p1.setOid("21337");
			p1.setGeburtstag(new Date(1983,04,05));

			System.out.println("PERSON ERSTELLEN BEENDEN");
			// --- Adresse ---
			 * 
			Adresse a1 = new Adresse();
			a1.addPerson(p1);
			a1.setOid("231");
			a1.setZip(29364);
			a1.setOrt("Langlingen");
			a1.setStrasse("Finkenweg");
*/
		
			
			PersonDbBroker.exemplar();
			//Person p1 = (Person) PersonDbBroker.exemplar().getObject("21337", Person.class);
			Person p1 = (Person) Broker.getObject("21337", Person.class);
			
			//p1.setName("naaaa");
			//p1.setName("been", "nii");
			System.out.println(p1.toString());
			
			//Adresse a1 = (Adresse) Broker.getObject("231", Adresse.class);
			Adresse a1 = (Adresse) AdresseDbBroker.exemplar().getObject("231", Adresse.class);

			//a1.addPerson(p1);
			a1.setOrt("blbllbl");
			
			
			
			// --- Transaktion ---
			System.out.println("TRANSACTION ADDEN ERSTELLEN BEGINNEN");
			Transaction t1 = new Transaction();
			System.out.println("TRANSACTION ADDEN ERSTELLEN BEENDEN");
			
			t1.addObject(p1);
			t1.addObject(a1);
			
			System.out.println("TRANSACTION ERSTELLEN BEGINNEN");
			t1.transactionCommit();
			
			System.out.println("TRANSACTION ERSTELLEN beenden");
			System.out.println("ERSTELLEN ENDE");
			
		} catch (Exception e) {
			e.printStackTrace();
		}

	}

}
